//
//  TeamView.m
//  MY Project For Sport
//
//  Created by dllo on 16/2/24.
//  Copyright © 2016年 dilo. All rights reserved.
//



#import "TeamView.h"
#import "ModelForMatch.h"
#import <SDWebImage/UIImageView+WebCache.h>
#import "ModelForManage2.h"
#import <DKNightVersion.h>
#import "UIColor+Wonderful.h"

#define WIDTH self.contentView.frame.size.width
#define HEIGHT self.contentView.frame.size.height


#define WEIGHTT [UIScreen mainScreen].bounds.size.width / 375
#define HEIGHTT [UIScreen mainScreen].bounds.size.height / 667

@interface TeamView ()

@property (nonatomic, retain) UIImageView *myView;
@property (nonatomic, retain) UIImageView *teamView;
@property (nonatomic, retain) UILabel *labelForName;
@property (nonatomic, retain) UIView *whiteLine;
@property (nonatomic, retain) UIView *whiteLine2;
@property (nonatomic, retain) UILabel *labelForNumber;
@property (nonatomic, retain) UIVisualEffectView *visualView;


@end

@implementation TeamView
-(void)dealloc {
    
    [_myView release];
    [_teamView release];
    [_labelForName release];
    [_whiteLine release];
    [_whiteLine2 release];
    [_labelForNumber release];
    [_number release];
    [_visualView release];
    [super dealloc];

}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        self.contentView.dk_backgroundColorPicker = DKColorWithColors([UIColor linenColor], [UIColor grayColor]);

        [self createSubview];
    }

    return self;
}

- (void)createSubview {
 
    
    self.myView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.myView];
    [_myView release];

    
    self.teamView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.teamView];
    [_teamView release];
    
    self.whiteLine = [[UIView alloc] init];
    [self.contentView addSubview:self.whiteLine];
    [_whiteLine release];
    
    self.whiteLine2 = [[UIView alloc] init];
    [self.contentView addSubview:self.whiteLine2];
    [_whiteLine2 release];
    
    self.labelForName = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForName];
    [_labelForName release];
    
    self.labelForNumber = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForNumber];
    [_labelForNumber release];
    
    self.number = [[UILabel alloc] init];
    [self.contentView addSubview:self.number];
    [_number release];
    
    self.visualView = [[UIVisualEffectView alloc] init];
    [self.myView addSubview:self.visualView];
    [_visualView release];
    
    
}

- (void)layoutSubviews {

    [super layoutSubviews];

    
    self.myView.frame = CGRectMake(- 100 * WEIGHTT, 2 * HEIGHTT, WIDTH + 200 * WEIGHTT , HEIGHT - 4 * HEIGHTT);
    self.myView.layer.cornerRadius = 5;
    self.myView.layer.masksToBounds = YES;
   
    self.teamView.frame = CGRectMake(WIDTH / 5 * 2, HEIGHT / 5 , WIDTH / 5, HEIGHT / 4);
     //self.teamView.backgroundColor = [UIColor redColor];
    
    self.labelForName.frame = CGRectMake(WIDTH / 4, HEIGHT / 5 + HEIGHT / 4 + 5 * HEIGHTT, WIDTH / 2, HEIGHT / 8);
   // self.labelForName.backgroundColor = [UIColor yellowColor];
    
    self.whiteLine.frame = CGRectMake(WIDTH / 5 * 2, HEIGHT / 5 + HEIGHT / 4 + 5 * HEIGHTT + HEIGHT / 8 + HEIGHT / 8, WIDTH / 5, 2 * HEIGHTT);
    self.whiteLine.backgroundColor = [UIColor whiteColor];
    
    self.labelForNumber.frame = CGRectMake(WIDTH / 5 * 2, HEIGHT / 5 + HEIGHT / 4  + HEIGHT / 8 + HEIGHT / 8 + 10 * HEIGHTT, WIDTH / 5, HEIGHT / 17);
   // self.labelForNumber.backgroundColor = [UIColor orangeColor];
    
    self.number.frame = CGRectMake(WIDTH / 5 * 2 + 5 * WEIGHTT, HEIGHT / 5 + HEIGHT / 4  + HEIGHT / 8 + HEIGHT / 8  + HEIGHT / 17 + 13 * HEIGHTT, WIDTH - (WIDTH / 5 * 2 + 5 * WEIGHTT) * 2, HEIGHT / 12);
    //self.number.backgroundColor = [UIColor greenColor];
    
    self.whiteLine2.frame = CGRectMake(WIDTH / 5 * 2, HEIGHT / 5 + HEIGHT / 4 + HEIGHT / 8 + HEIGHT / 8 + HEIGHT / 17  + HEIGHT / 12 + 18 * HEIGHTT, WIDTH / 5, 2 * HEIGHTT);
    
    self.whiteLine2.backgroundColor = [UIColor whiteColor];
    
    
    UIBlurEffect *blur = [UIBlurEffect effectWithStyle:2];
    self.visualView.frame = self.myView.frame;
    self.visualView.effect = blur;
    
    
   // self.visualView.alpha = 0.8;
    
}

- (void)passModel:(ModelForManage2 *)model {
    

    
    [self.myView sd_setImageWithURL:[NSURL URLWithString:model.logo_big]];
   // self.myView.alpha = 0.8;
    
    [self.teamView sd_setImageWithURL:[NSURL URLWithString:model.logo_big]];

    self.labelForName.text = model.name_cn;
    self.labelForName.textAlignment = NSTextAlignmentCenter;
    self.labelForName.font = [UIFont systemFontOfSize:18];
    self.labelForName.textColor = [UIColor whiteColor];
    
    self.labelForNumber .text = @"签到排名";
    self.labelForNumber.textAlignment = NSTextAlignmentCenter;
    self.labelForNumber.font = [UIFont systemFontOfSize:12];
    self.labelForNumber.textColor = [UIColor whiteColor];

    
    //self.number.text = @"NO.12";
    self.number.textAlignment = NSTextAlignmentCenter;
    self.number.font = [UIFont systemFontOfSize:15];
    self.number.textColor = [UIColor whiteColor];

    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
